<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>watch</title>
</head>
<body>
    <div id="app">
        <p>{{msg}}</p>
        <button @click="msg='world hello'">改变msg</button>
    </div>
</body>
<script src='../js/vue.js '></script>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
             msg:'hello world'
        },
        watch:{
            "msg":function(newVal,oldval){
                console.log(`监听msg改变前是${oldval},改变后是${newVal}`)
            }
        }
    })
</script>
</html>